<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    {{if $meta==1}}
    <meta http-equiv="Refresh" content="1; url=http://wap.nianhui.jinfuyingui.com.cn"/>
    {{/if}}
    <title>签到入口</title>
    <link rel="stylesheet" href="/templates/default/css/frozen.css">
    <link rel="stylesheet" href="/templates/default/css/style.css">
    <script src="/templates/default/js/lib/zepto.min.js"></script>
    <script src="/templates/default/js/frozen.js"></script>
</head>
<body>
<section class="ui-container">
    <div class="head">
        <img class="bg_img" src="/templates/default/images/login.jpg" alt="签到背景" ></div>

    <!--1.倒计时-->
    {{if $date_state=='not_start'}}
    <div class="form clock" id="not_start">
        <div style="">
            <p style="
			font-weight: bold;
			margin-bottom: 10px;
			color: #e10024;
		">活动开始倒计时</p>
            <p style="
			font-weight: bold;
			font-size: 24px;
			color: #e10024;
		">
                <span id="t_d">00天</span>
                <span id="t_h">00时</span>
                <span id="t_m">00分</span>
                <span id="t_s">00秒</span>
        </div>
    </div>
    {{/if}}

    <!--2.输入手机号-->
    {{if $date_state=='can_sign'}}
    <div class="form" style="top:58%" id="can_sign">
        <div style="
		    font-size: 15px;
			width: 65%;
			margin: 0 auto;
			color: #e10024;
			font-weight: bold;
			margin-bottom: 15px;
		">
            填写姓名及身份证号后四位完成签到验证，即可参与投票活动。
        </div>
        <form action="">
            <!--<p>部门：
                <select id="company" name="company" class="mobile">
                    <option value="">---请选择部门---</option>
                    {{foreach from=$company_list item=i key=key}}
                        <option value="{{$i.department1}}">{{$i.department1}}</option>
                    {{/foreach}}
                </select>
            </p>
            <p style="margin-top: 5px;">
                <select id="dept2" name="dept2" class="mobile" style="margin-left: 52px;">
                    <option value="">---请选择部门---</option>
                </select>
            </p>-->
            <div style="margin-top: 5px; width: 100%; overflow: hidden;">
                <div style="width: 25%; float: left; margin-left: 30px; line-height: 38px;">姓名：</div>
                <div style="width: 55%; float: left; text-align: left"><input type="text" class="mobile" placeholder='请输入姓名' id="name"></div>
            </div>
            <div style="margin-top: 5px; width: 100%; overflow: hidden;">
                <div style="width: 25%; float: left; margin-left: 30px; line-height: 38px;">身份证号：</div>
                <div style="width: 55%; float: left; text-align: left"><input type="text" class="mobile" placeholder='请输入身份证号后四位' id="identity"></div>
            </div>
            <div style="margin-top: 5px; width: 100%;overflow: hidden">
                <input type="button" class="sign" id="type_2">
            </div>
        </form>
    </div>
    {{/if}}

    {{if $date_state=='game_over'}}
    <!--3.活动结束-->
    <div class="form" id="game_over">
        <div style="">
        <p style="
            font-size: 24px;
            color: #e10024;
            font-weight: bold;
            margin-top: 30px;
        ">活动已结束</p>
        </div>
    </div>
    {{/if}}
</section>
<div class="ui-dialog">
    <div class="ui-dialog-cnt" style="width:90%; background:none;">

        <img src="/templates/default/images/comfrim.jpg" style="width:100%;border:none;" alt="">

        <div class="ui-dialog-ft" style="
            position: absolute;
            top: 76%;
            color: rgba(0,0,0,0);
			border:none;
			padding:0;
			margin:0;
        ">
            <button type="button" data-role="button" style="color:rgba(0,0,0,0);" onclick="cancel()">返回</button>
        </div>
    </div>
</div>
<script class="demo-script">
    $("select[name='company']").change(function() {
        var selected_value = $(this).val();
        if(selected_value==''){
            $("select[name='dept2']").empty();
            var option_null = $("<option>").val('').text('---请选择部门---');
            $("select[name='dept2']").append(option_null);
            return;
        }
        $.ajax({
            url: '/home/index/getGroupbyCom',
            data: {
                company: selected_value
            },
            type: 'POST',
            dataType: 'json',
            success: function (datas) {
                $("select[name='dept2']").empty();
                //循环添加
               // var option_null = $("<option>").val('').text('---请选择部门---');
               // $("select[name='dept2']").append(option_null);

                for(var i = 0; i < datas.length; i++) {
                    var option = $("<option>").val(datas[i]['department2']).text(datas[i]['department2']);
                    $("select[name='dept2']").append(option);
                }
            },
            error: function () {
                alert("请重新选择！");
            }
        });
    });

    $(".sign").click(function(){
        var this_id = $(this).attr('id');
        //var dept1 = $('#company').val();
        //var dept2 = $('#dept2').val();
        var name = $.trim($('#name').val());
        var identity = $.trim($('#identity').val());

        if(identity!='' && name!='') {
            var url = '/home/index/checklogin';
            $.ajax({
                url: url,
                data: {
                    identity: identity,
                    name: name
                },
                type: 'POST',
                cache: false,
                dataType: 'html',
                success: function (data) {
                    if (data=='success') {
                        if(this_id=='type_1'){location.href = '/home/index/articleList';}
                        else {location.href = '/home/index/articleVote3';}
                    } else if (data == 'fail') {
                        //alert('抱歉,您未加入活动邀请名单,无法继续参与投票活动');
                        $(".ui-dialog").addClass("show");
                    } else {
                        alert(data);
                    }
                },
                error: function () {
                    //alert("AJAX异常！");
                }
            });
        }
    })

    function cancel(){
        $(".ui-dialog").removeClass("show");
    }

    /*if($(".clock").length>0){


        var TheEndTime = $('#start_date_set').html();
        var clock = setInterval(function(){GetRTime(TheEndTime)},0);

        function GetRTime(EndTime){
            var EndTime= new Date(EndTime);
            var NowTime = new Date();
            var t =EndTime.getTime() - NowTime.getTime();
            var d=0;
            var h=0;
            var m=0;
            var s=0;
            if(t>=0){
                d=Math.floor(t/1000/60/60/24);
                h=Math.floor(t/1000/60/60%24);
                m=Math.floor(t/1000/60%60);
                s=Math.floor(t/1000%60);
            }
            if((d+h+m+s)===0){

                echo_time(0,0,0,0)
                clearTimeout(clock);
                //时间到，跳转到签到输入页面；
                //location.href = '/home/index/articleVote3';
            }else{
                echo_time(d,h,m,s)
            }

        }


        function echo_time(d,h,m,s){

            $(".time_d").text(d)
            $(".time_h").text(h)
            $(".time_i").text(m)
            $(".time_s").text(s)

        }

    }*/
</script>
</body>
</html>
<!--倒计时-->
<script>
    var timer1;
    function GetRTime(){
        //var EndTime= new Date('2017/01/20 09:09:00');
        var EndTime= new Date('{{$start_date}}');
        var NowTime = new Date();
        var t =EndTime.getTime() - NowTime.getTime();
        var d=Math.floor(t/1000/60/60/24);
        var h=Math.floor(t/1000/60/60%24);
        var m=Math.floor(t/1000/60%60);
        var s=Math.floor(t/1000%60);
        document.getElementById("t_d").innerHTML = d + "天";
        document.getElementById("t_h").innerHTML = h + "时";
        document.getElementById("t_m").innerHTML = m + "分";
        document.getElementById("t_s").innerHTML = s + "秒";
        if(d+h+m+s==0){
            clearInterval(timer1);
            location.href = '/home/index/articleVote3';return;
        }
    }
    timer1 = setInterval(GetRTime,0);
</script>